<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link href="../lib/bootstrap-3.3.7.css" rel="stylesheet">
    <style>
        .sign {
            width: 700px;
            height: 360px;
            position: absolute;
            top: 50%;
            left: 50%;
            margin-top: -180px;
            margin-left: -350px;
            background-color: #d9534f;
            padding: 0 100px;
        }
        .sign h3{
            text-align: center;
            padding: 50px 0;
            font-weight: 700;
            color: white;
        }
        .sign .form-horizontal label{
            color: #fff;
        }
        .sign .form-horizontal .form-group .register{
            float: right;
        }

    </style>
    <script src="../lib/vue-2.4.0.js"></script>
    <script src="../node_modules/axios/dist/axios.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/js-cookie@2/src/js.cookie.min.js"></script>
    <script>
        let xhr = new XMLHttpRequest()
        xhr.open('POST','../login/validateLogin.php',false)
        xhr.onreadystatechange=function () {
            if(this.readyState===4){
               let data = JSON.parse(this.responseText)
                if(data.code==200){
                    if(Cookies.get('name')==data.data.name && Cookies.get('password')==data.data.password ){
                        location.href='student.html'
                    }
                }
            }else{
                alert("服务器出错")
            }
        }
        xhr.send()

    </script>
</head>
<body>
    <div class="sign" id="dv">
        <h3>欢迎登录学生选课系统</h3>
        <form class="form-horizontal">
            <div class="form-group">
                <label for="inputEmail3" class="col-sm-2 control-label">用户名</label>
                <div class="col-sm-10">
                    <input type="text" class="form-control" id="inputEmail3" placeholder="请输入用户名" v-model="username">
                </div>
            </div>
            <div class="form-group">
                <label for="inputPassword3" class="col-sm-2 control-label">密码</label>
                <div class="col-sm-10">
                    <input type="password" class="form-control" id="inputPassword3" placeholder="请输入密码" v-model="userpassword">
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-offset-2 col-sm-10">
                    <div class="checkbox">
                        <label>
                            <input type="checkbox" true-value="1" false-value="0" v-model.number="autosign"> 下次自动登录
                        </label>
                        <a href="register.html" class="register">注册</a>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-offset-2 col-sm-10">
                    <button type="button" class="btn btn-primary btn-block" @click="sign">登录</button>
                </div>
            </div>
        </form>
    </div>
<script src="../js/sign.js"></script>
</body>
</html>